'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, jwt, middleware } = app;
  const jwtErr = middleware.jwtErr(app.config.jwt)

  require('./router/user')(app);
  app.router.get('/qiniu/getToken', app.controller.qiniu.getToken);
  require('./router/app')(app);

  app.router.get('/api/pms', app.controller.pms.index);

  // router.get('/', controller.home.index);

  app.router.get('/admin/auth/userList', app.controller.admin.userList);

  app.router.post('/admin/auth/login', app.controller.admin.login);
  app.router.post('/admin/auth/token', jwtErr, app.controller.admin.getUserInfo);
  app.router.post('/admin/auth/loginOut', jwtErr, app.controller.admin.loginOut);
  app.router.get('/category/index', jwtErr, app.controller.category.index);
  app.router.post('/category/store', jwtErr, app.controller.category.store);
  app.router.get('/category/remove', jwtErr, app.controller.category.remove);
  app.router.get('/category/detail', jwtErr, app.controller.category.detail);



  app.router.post('/admin/basicResources/index', jwtErr, app.controller.basicResources.index);
  app.router.post('/admin/basicResources/remove', jwtErr, app.controller.basicResources.remove);
  app.router.post('/admin/basicResources/store', jwtErr, app.controller.basicResources.store);

  app.io.route('/disconnect', app.controller.chat.disconnect);

  // app.router.post('/wxtest/getopenid', app.controller.wx.getopenid);
  app.router.post('/wxtest/getPhoneNumber', app.controller.wx.getPhoneNumber);
  app.router.get('/wxtest/pms', app.controller.pms.index);
  app.router.get('/wxtest/area_info', app.controller.wx.area_info);



  app.router.post('/api/wechat/mp_auth', app.controller.wx.getopenid);




  app.router.post('/save_error_logger', app.controller.logger.index);



};

